package com.weimengchao;

import com.weimengchao.common.algorithm.SnowflakeManager;
import com.weimengchao.dao.OrderInfoDao;
import com.weimengchao.entity.OrderInfo;
import org.junit.jupiter.api.Test;

import javax.annotation.Resource;

/**
 * @description:
 * @author: 魏孟超
 * @createDate: 2021-09-13 22:57
 */
public class ShardingDemo extends ShardingExampleApplicationTests {

    @Resource
    OrderInfoDao orderInfoDao;

    @Test
    public void insert() throws Exception {
        SnowflakeManager snowflakeManager = new SnowflakeManager(0, 0);
        long orderId = snowflakeManager.nextValue();
        for (int i = 0; i < 100; i++) {
            OrderInfo orderInfo = new OrderInfo();
            orderInfo.setOrderId(orderId);
            orderInfoDao.save(orderInfo);
            orderId++;
        }
    }

}
